package com.gcb.common.enums;

import java.util.Arrays;
import java.util.Optional;

/**
 * 账号状态
 */
public enum UserTagEnum {
    BROKER("1", "代理"),
    CREW("2", "船员"),
    shipowner("3", "船东"),
    GOODsOwner("4", "货主"),
    FREIGHTFORWARD("5", "货代"),
    VENDOR("6", "供应商"),
    ANOTHER("7", "其他");

    private final String code;
    private final String info;

    UserTagEnum(String code, String info) {
        this.code = code;
        this.info = info;
    }

    public String getCode() {
        return code;
    }

    public String getInfo() {
        return info;
    }

    public static String getInfo(String type) {
        return Optional.ofNullable(of(type))
                .map(UserTagEnum::getInfo)
                .orElse("");
    }

    public static UserTagEnum of(String code) {
        Optional<UserTagEnum> first = Arrays.stream(UserTagEnum.values()).filter(v -> v.getCode().equals(code)).findFirst();
        return first.orElse(null);
    }
}
